package com.jingdianjichi.subject.handler.subject;

import com.jingdianjichi.subject.common.enums.SubjectInfoTypeEnum;
import com.jingdianjichi.subject.common.enums.isDeletedFlagEnum;
import com.jingdianjichi.subject.converter.BriefSubjectConverter;
import com.jingdianjichi.subject.eneity.SubjectInfoBO;
import com.jingdianjichi.subject.eneity.SubjectOptionBO;
import com.jingdianjichi.subject.infra.basic.entity.SubjectBrief;
import com.jingdianjichi.subject.infra.basic.service.SubjectBriefService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.security.auth.Subject;
import java.util.Collection;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.FutureTask;

/**
 * 简答题枚举类
 */
@Component
public class BriefTypeHandler implements SubjectTypeHandler{
    @Resource
    private SubjectBriefService subjectBriefService;

    @Override
    public SubjectInfoTypeEnum getHandlerType() {
        return SubjectInfoTypeEnum.BIREF;
    }

    @Override
    public void add(SubjectInfoBO subjectInfoBO) {
        SubjectBrief subjectBrief = BriefSubjectConverter.INSTANCE.converterBoToCategory(subjectInfoBO);
        subjectBrief.setIsDeleted(isDeletedFlagEnum.UN_DELETED.getCode());
        subjectBrief.setSubjectId(subjectInfoBO.getId().intValue());
        subjectBriefService.insert(subjectBrief);
    }


    @Override
    public SubjectOptionBO query(int subjectId) {
        SubjectBrief subjectBrief = new SubjectBrief();
        subjectBrief.setSubjectId(subjectId);
        SubjectBrief result = subjectBriefService.queryByCondition(subjectBrief);
        SubjectOptionBO subjectOptionBO = new SubjectOptionBO();
        subjectOptionBO.setSubjectAnswer(result.getSubjectAnswer());
        return  subjectOptionBO;
    }


}
